syntax = "proto3";

package kuma.mesh.v1alpha1;

option go_package = "github.com/kumahq/kuma/api/mesh/v1alpha1";

import "api/mesh/options.proto";

message ServiceInsight {

  option (kuma.mesh.resource).name = "ServiceInsightResource";
  option (kuma.mesh.resource).type = "ServiceInsight";
  option (kuma.mesh.resource).package = "mesh";
  option (kuma.mesh.resource).kds.send_to_zone = true;
  option (kuma.mesh.resource).ws.name = "service-insight";
  option (kuma.mesh.resource).ws.read_only = true;

  reserved 1; // formerly last_sync

  message Service {
    option (kuma.mesh.resource).name = "ServiceOverviewResource";
    option (kuma.mesh.resource).type = "ServiceOverview";
    option (kuma.mesh.resource).package = "mesh";
    option (kuma.mesh.resource).skip_registration = true;
    option (kuma.mesh.resource).skip_kubernetes_wrappers = true;

    enum Status {
      none = 0; // should not be used
      offline = 1;
      partially_degraded = 2;
      online = 3;
      not_available = 4;
    }

    Status status = 1;

    message DataplaneStat {
      uint32 total = 1;
      uint32 online = 2;
      uint32 offline = 3;
    }

    DataplaneStat dataplanes = 2;

    map<string, uint32> issuedBackends = 3;

    enum Type {
      internal = 0;
      external = 1;
      gateway_delegated = 2;
      gateway_builtin = 3;
    }
    Type serviceType = 4;
    string addressPort = 5;
  }

  map<string, Service> services = 2;
}
